<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
   
</head>
<body>

     <script>
        class Father{
            constructor(x,y){
                this.x=x;
                this.y=y;
                this.sum();/* 调用自身的函数 */
            }
            sum(){
                console.log(this.x+this.y);/* 共有属性和方法加this使用 */
            }
            say(){
                console.log("hello");
            }
        }
        class Son extends Father{
            constructor(x,y){
                super(x,y);/* 调用父类构造函数,因为父类的sum方法要用到父类构造函数的参数 *//* 父类构造函数要放在子类构造函数（this）前 */
                super.say();/* 调用父类普通函数 */
                this.x=x;
                this.y=y;
            }
        }
        var son=new Son(10,20);/* 先定义类，再实例化对象 */
       /*  son.sum(); */
    </script>
</body>
</html>